home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.06 Jun 93 / C Shell XCMD / BGetTCLInfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-05  |  2.0 KB  |  88 lines  |  [TEXT/KAHL]

  1. /*******************************************************************
  2.  * BGetTCLInfo.c
  3.  *
  4.  * SUPERCLASS = CDLOGDirector
  5.  *
  6.  * Dialog class which prompts user for information and then return his input.
  7.  *  
  8.  * © copyright 1991, KSS Scientific Consultants.
  9.  *
  10.  ******************************************************************/
  11.  
  12. #include <CDialogText.h>
  13. #include <CWindow.h>
  14. #include <Commands.h>
  15. #include <string.h>
  16. #include "BGetTCLInfo.h"
  17.  
  18. enum    // dialog item IDs
  19. {
  20.     kReturnStr = 2,
  21.     kPrompt
  22. };
  23.  
  24. /*******************************************************************
  25.  * IBGetTCLInfo()
  26.  *
  27.  * Initialization method.
  28.  *
  29.  *******************************************************************/
  30.  
  31. void BGetTCLInfo::IBGetTCLInfo(short DLOGid, CDirectorOwner *aSupervisor)
  32. {
  33.     CDLOGDirector::IDLOGDirector(DLOGid, aSupervisor);
  34. }
  35.  
  36. /**********************************************************************
  37.  * DoCommand()
  38.  *
  39.  * *******************************************************************/
  40.  
  41. void BGetTCLInfo::DoCommand(long theCommand)
  42. {
  43.     CDialogText        *theText;
  44.     short            length;
  45.     
  46.     switch (theCommand)
  47.     {
  48.         case cmdOK:
  49.             theText = (CDialogText*)itsWindow->FindViewByID(kReturnStr);
  50.             length = (**theText->macTE).teLength;
  51.             BlockMove(*(**theText->macTE).hText, fReturnStr, length);
  52.             fReturnStr[length] = '\0';
  53.             EndDialog( cmdOK, TRUE);
  54.             break;
  55.  
  56.         default:
  57.             inherited::DoCommand(theCommand);
  58.             break;
  59.     }
  60.     
  61. }
  62.  
  63. /*********************************************************************
  64.  * GetInfo()
  65.  *
  66.  * Entry method.
  67.  *
  68.  *********************************************************************/
  69.  
  70. void BGetTCLInfo::GetInfo(char *promptPtr, char *returnPtr)
  71. {
  72.     long            theCommand;
  73.     CDialogText        *staticItem;
  74.     Str255            tempStr;
  75.     
  76.     strcpy((char*)tempStr, promptPtr);
  77.     CtoPstr((char*)tempStr);
  78.     staticItem = (CDialogText*)itsWindow->FindViewByID(kPrompt);
  79.     staticItem->SetTextString(tempStr);
  80.  
  81.     // show the dialog
  82.     BeginDialog();
  83.     
  84.     theCommand = DoModalDialog(cmdOK);
  85.     
  86.     strcpy(returnPtr, (char*)fReturnStr);
  87. }
  88.